﻿using ComLib.ConfigService;
using LogLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace SignatureBoard
{
    class SignatureBoardOption : IniConfigBase
    {
        public override string ConfigDirectory
        {
            get
            {
                string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                directory = directory.Substring(6);
                return directory;
            }
        }

        public override string ConfigFilePath
        {
            get
            {
                if (string.IsNullOrEmpty(_strConfigPath))
                {
                    string className = this.GetType().Name;
                    _strConfigPath = Path.Combine(ConfigDirectory, className + ".ini");
                }
                return _strConfigPath;
            }
        }

        public SignatureBoardOption() : base()
        {
        }

        /// <summary>
        /// licence
        /// </summary>
        private string _licence = "";
        public string Licence
        {
            get { return _licence; }
            set { _licence = value; }
        }       

        public override bool Load()
        {
            base.Load();
            try
            {                
                _licence = LoadStringValue("licence");
            }
            catch (Exception ex)
            {
                string strMsg = string.Format("配置文件{0}加载错误:\n\t{1}", ConfigFilePath, ex.Message);
                Log.WriteException(ex.ToString());
                return false;
            }
            return true;
        }
        public override bool Save()
        {
            base.Save();
            SaveField("licence", "AgAkAEy2cKydAQVXYWNvbQ1TaWduYXR1cmUgU0RLAgKBAgJkAACIAwEDZQA");       
            return true;
        }
    }
}
